/*
 * jxUtils Project (2013, 2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxUtils.system;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Denilson Edinaldo Pinto
 * @project jxUtils
 * @package org.jxUtils.system
 * @date 01/04/2013 - 17:32:12
 */
public final class SystemProperties {
	
	private static final String FILE_SEPARATOR = System.getProperty("file.separator");
	
	private static final String JAVA_CLASS_PATH = System.getProperty("java.class.path");
	
	private static final String JAVA_CLASS_VERSION = System.getProperty("java.class.version");
	
	private static final String JAVA_COMPILER = System.getProperty("java.compiler");
	
	private static final String JAVA_EXT_DIRS = System.getProperty("java.ext.dirs");
	
	private static final String JAVA_HOME = System.getProperty("java.home");
	
	private static final String JAVA_IO_TMPDIR = System.getProperty("java.io.tmpdir");
	
	private static final String JAVA_LIBRARY_PATH = System.getProperty("java.library.path");
	
	private static final String JAVA_SPECIFICATION_NAME = System.getProperty("java.specification.name");
	
	private static final String JAVA_SPECIFICATION_VENDOR = System.getProperty("java.specification.vendor");
	
	private static final String JAVA_SPECIFICATION_VERSION = System.getProperty("java.specification.version");
	
	private static final String JAVA_VENDOR = System.getProperty("java.vendor");
	
	private static final String JAVA_VENDOR_URL = System.getProperty("java.vendor.url");
	
	private static final String JAVA_VERSION = System.getProperty("java.version");
	
	private static final String JAVA_VM_NAME = System.getProperty("java.vm.name");
	
	private static final String JAVA_VM_SPECIFICATION_NAME = System.getProperty("java.vm.specification.name");
	
	private static final String JAVA_VM_SPECIFICATION_VENDOR = System.getProperty("java.vm.specification.vendor");
	
	private static final String JAVA_VM_SPECIFICATION_VERSION = System.getProperty("java.vm.specification.version");
	
	private static final String JAVA_VM_VENDOR = System.getProperty("java.vm.vendor");
	
	private static final String JAVA_VM_VERSION = System.getProperty("java.vm.version");
	
	private static final String LINE_SEPARATOR = System.getProperty("line.separator");
	
	private static final String OS_ARCH = System.getProperty("os.arch");
	
	private static final String OS_NAME = System.getProperty("os.name");
	
	private static final String OS_VERSION = System.getProperty("os.version");
	
	private static final String PATH_SEPARATOR = System.getProperty("path.separator");
	
	private static final String USER_DIR = System.getProperty("user.dir");
	
	private static final String USER_HOME = System.getProperty("user.home");
	
	private static final String USER_NAME = System.getProperty("user.name");
	
	private static List<String> properties = null;
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
	
		return getString();
	}
	
	/**
	 * @return the fileSeparator
	 */
	public static String getFileSeparator() {
	
		return FILE_SEPARATOR;
	}
	
	/**
	 * @return the javaClassPath
	 */
	public static String getJavaClassPath() {
	
		return JAVA_CLASS_PATH;
	}
	
	/**
	 * @return the javaClassVersion
	 */
	public static String getJavaClassVersion() {
	
		return JAVA_CLASS_VERSION;
	}
	
	/**
	 * @return the javaCompiler
	 */
	public static String getJavaCompiler() {
	
		return JAVA_COMPILER;
	}
	
	/**
	 * @return the javaExtDirs
	 */
	public static String getJavaExtDirs() {
	
		return JAVA_EXT_DIRS;
	}
	
	/**
	 * @return the javaHome
	 */
	public static String getJavaHome() {
	
		return JAVA_HOME;
	}
	
	/**
	 * @return the javaIoTmpdir
	 */
	public static String getJavaIoTmpdir() {
	
		return JAVA_IO_TMPDIR;
	}
	
	/**
	 * @return the javaLibraryPath
	 */
	public static String getJavaLibraryPath() {
	
		return JAVA_LIBRARY_PATH;
	}
	
	/**
	 * @return the javaSpecificationName
	 */
	public static String getJavaSpecificationName() {
	
		return JAVA_SPECIFICATION_NAME;
	}
	
	/**
	 * @return the javaSpecificationVendor
	 */
	public static String getJavaSpecificationVendor() {
	
		return JAVA_SPECIFICATION_VENDOR;
	}
	
	/**
	 * @return the javaSpecificationVersion
	 */
	public static String getJavaSpecificationVersion() {
	
		return JAVA_SPECIFICATION_VERSION;
	}
	
	/**
	 * @return the javaVendor
	 */
	public static String getJavaVendor() {
	
		return JAVA_VENDOR;
	}
	
	/**
	 * @return the javaVendorUrl
	 */
	public static String getJavaVendorUrl() {
	
		return JAVA_VENDOR_URL;
	}
	
	/**
	 * @return the javaVersion
	 */
	public static String getJavaVersion() {
	
		return JAVA_VERSION;
	}
	
	/**
	 * @return the javaVmName
	 */
	public static String getJavaVmName() {
	
		return JAVA_VM_NAME;
	}
	
	/**
	 * @return the javaVmSpecificationName
	 */
	public static String getJavaVmSpecificationName() {
	
		return JAVA_VM_SPECIFICATION_NAME;
	}
	
	/**
	 * @return the javaVmSpecificationVendor
	 */
	public static String getJavaVmSpecificationVendor() {
	
		return JAVA_VM_SPECIFICATION_VENDOR;
	}
	
	/**
	 * @return the javaVmSpecificationVersion
	 */
	public static String getJavaVmSpecificationVersion() {
	
		return JAVA_VM_SPECIFICATION_VERSION;
	}
	
	/**
	 * @return the javaVmVendor
	 */
	public static String getJavaVmVendor() {
	
		return JAVA_VM_VENDOR;
	}
	
	/**
	 * @return the javaVmVersion
	 */
	public static String getJavaVmVersion() {
	
		return JAVA_VM_VERSION;
	}
	
	/**
	 * @return the lineSeparator
	 */
	public static String getLineSeparator() {
	
		return LINE_SEPARATOR;
	}
	
	/**
	 * @return the osArch
	 */
	public static String getOsArchitecture() {
	
		return OS_ARCH;
	}
	
	/**
	 * @return the osName
	 */
	public static String getOsName() {
	
		return OS_NAME;
	}
	
	/**
	 * @return the osVersion
	 */
	public static String getOsVersion() {
	
		return OS_VERSION;
	}
	
	/**
	 * @return the pathSeparator
	 */
	public static String getPathSeparator() {
	
		return PATH_SEPARATOR;
	}
	
	/**
	 * @return System Properties
	 */
	public static List<String> getProperties() {
	
		//
		if(properties == null) {
			properties = new ArrayList<String>();
			properties.add("JAVA VERSION = " + JAVA_VERSION);
			properties.add("JAVA VENDOR = " + JAVA_VENDOR);
			properties.add("JAVA VENDOR URL = " + JAVA_VENDOR_URL);
			properties.add("JAVA HOME = " + JAVA_HOME);
			properties.add("JAVA VM SPECIFICATION VERSION = " + JAVA_VM_SPECIFICATION_VERSION);
			properties.add("JAVA VM SPECIFICATION VENDOR = " + JAVA_VM_SPECIFICATION_VENDOR);
			properties.add("JAVA VM SPECIFICATION NAME = " + JAVA_VM_SPECIFICATION_NAME);
			properties.add("JAVA VM VERSION = " + JAVA_VM_VERSION);
			properties.add("JAVA VM VENDOR = " + JAVA_VM_VENDOR);
			properties.add("JAVA VM NAME = " + JAVA_VM_NAME);
			properties.add("JAVA SPECIFICATION VERSION = " + JAVA_SPECIFICATION_VERSION);
			properties.add("JAVA SPECIFICATION VENDOR = " + JAVA_SPECIFICATION_VENDOR);
			properties.add("JAVA SPECIFICATION NAME = " + JAVA_SPECIFICATION_NAME);
			properties.add("JAVA CLASS VERSION = " + JAVA_CLASS_VERSION);
			properties.add("JAVA CLASS PATH = " + JAVA_CLASS_PATH);
			properties.add("JAVA LIBRARY PATH = " + JAVA_LIBRARY_PATH);
			properties.add("JAVA IO TMPDIR = " + JAVA_IO_TMPDIR);
			properties.add("JAVA COMPILER = " + JAVA_COMPILER);
			properties.add("JAVA EXT DIRS = " + JAVA_EXT_DIRS);
			properties.add("OS NAME = " + OS_NAME);
			properties.add("OS ARCH = " + OS_ARCH);
			properties.add("OS VERSION = " + OS_VERSION);
			properties.add("FILE SEPARATOR = " + FILE_SEPARATOR);
			properties.add("PATH SEPARATOR = " + PATH_SEPARATOR);
			properties.add("LINE SEPARATOR = " + LINE_SEPARATOR.replace("\n", "\\n"));
			properties.add("USER NAME = " + USER_NAME);
			properties.add("USER HOME = " + USER_HOME);
			properties.add("USER DIR = " + USER_DIR);
		}
		
		return properties;
	}
	
	/**
	 * @return System Properties
	 */
	public static String getString() {
	
		final StringBuilder systemProperties = new StringBuilder();
		
		// 
		for(final String propertie : getProperties()) {
			
			systemProperties.append(propertie + getLineSeparator());
		}
		
		return systemProperties.toString();
	}
	
	/**
	 * @return the userDir
	 */
	public static String getUserDir() {
	
		return USER_DIR;
	}
	
	/**
	 * @return the userHome
	 */
	public static String getUserHome() {
	
		return USER_HOME;
	}
	
	/**
	 * @return the userName
	 */
	public static String getUserName() {
	
		return USER_NAME;
	}
}
